﻿$(function () {


    $("#btnSearch").click(function () {
        $("#logTable").datagrid({
            url: '../../Handlers/LogHandler.aspx?op=search',
            method: "post",
            queryParams:
                {
                    startDate: $("#startDate").val(),
                    endDate: $("#endDate").val(),
                    logType: $("#logType").combobox("getValue"),
                    uid: $("#uid").combogrid("getValue"),
                    txtKeyw: $("#txtKeyw").val()
                },
            columns: [[
                    { field: "UserName",
                        title: lang.User_name,
                        width: 80,
                        align: 'center',
                        sortable: true
                    },
                    {
                        field: "UserAccount",
                        title: lang.account,
                        width: 80,
                        align: 'center',
                        sortable: true
                    },
                     {
                        field: "IP",
                        title: lang.IP_address,
                        width: 200,
                        align: 'center',
                        sortable: true
                    },
                    {
                        field: "OperateTime",
                        title: lang.operation_time,
                        width: 150,
                        align: 'center',
                        sortable: true
                    },
                    {
                        field: "LogDesc",
                        title: lang.log_contents,
                        width: 640,
                        align: 'left',
                        sortable: true
                    }
                   
                ]],
            rownumbers: true,
            animate: true,
            fit: true,
            pageSize: 20,
            pagination: true,
            singleSelect: true,
           // pagePosition: 'bottom',
            striped: true,
            remoteSort: false
        });

        //设置分页控件  
        var p = $('#logTable').datagrid('getPager');

        $(p).pagination({
            pageSize: 20, //每页显示的记录条数，默认为10  
            pageList: [20, 30], //可以设置每页记录条数的列表  
            beforePageText:'', //页数文本框前显示的汉字  
            afterPageText:"/{pages}",//lang.Page + "  " + lang.total + " {pages}" + lang.Page,
            //displayMsg: '',
            displayMsg: lang.current_show + " {from} - {to} " + lang.Record + "  " + lang.total + " {total} " + lang.Record

        });



    });

    $("#btnServerExport").click(function () {
        return true;
    });

    $("#btnExport").click(function () {
        //导出Excel
        $("#btnServerExport").click();
    });
    //清空日志
    $("#btnClear").click(function () {

        if (confirm(lang.clear_log + "?")) {

        $.post(

                    '../../Handlers/LogHandler.aspx?op=delete',
                    {
                        startDate: $("#startDate").val(),
                        endDate: $("#endDate").val(),
                        logType: $("#logType").combobox("getValue"),
                        uid: $("#uid").combogrid("getValue"),
                        txtKeyw: $("#txtKeyw").val()
                    },
                    function (data) {
                        if (data.success) {
                            alert(lang.Empty_uccess);
                            $("#btnSearch").click();
                        }
                        else {
                            alert(lang.Empty_false);
                        }
                    }
                );
      }
   
    });



    $("#btnSearch").click();



});

       